package logic

import (
	"context"
	"video-up-manager/videorpc/videorpc"

	"video-up-manager/api/internal/svc"
	"video-up-manager/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentDelApiLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCommentDelApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentDelApiLogic {
	return &CommentDelApiLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CommentDelApiLogic) CommentDelApi(req *types.CommentDelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	del, err := l.svcCtx.VideoRpc.CommentDel(l.ctx, &videorpc.CommentDelRequest{
		CommentId: req.CommentId,
		UserId:    req.UserId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "ok",
		Code:    200,
		Data:    del,
	}, nil
}
